# 生成一维码
from barcode.writer import ImageWriter
import barcode

#
def Create_BarCode(Data="001001001", Path = "Pic/BarCode/", FileName="FileName"):
    try:
        # print(barcode.PROVIDED_BARCODES)#查看python - barcode支持的条形码格式
        EAN = barcode.get_barcode_class('code128')  # 创建条形码格式对象
        ean = EAN(Data, writer=ImageWriter())  # 创建条形码对象
        return ean.save(Path + FileName)  # 保存条形码图片,自带png后缀，返回图片路径
    except:
        return False

if __name__ == '__main__':
    res = Create_BarCode(Data="99999")
    print(res)